package com.example.demo.javatest.jdk8;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/**
 * @author ljh
 * @create 2020/7/27
 * @describe
 */
public class JavaDateParse {
    private  static  String date="Fri Jul 24 08:11:30 +0000 2020";
    public static void main(String[] args) {


    }

    /**
     * "Fri Jul 24 08:11:30 +0000 2020"
     * SimpleDateFormat 有时区的概念
     */
    public static  void  fun1(){

        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss Z yyyy", Locale.ENGLISH);
        try {
            System.out.println(formatter.parse(date));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    /**
     * LocalDateTime 无时区的概念
     */
    public  static  void fun2(){
        System.out.println(LocalDateTime.parse(date, DateTimeFormatter.ofPattern("EEE MMM d HH:mm:ss Z yyyy",Locale.ENGLISH)));
    }
}
